package cn.scu.ne04jdemo.controller;

import cn.scu.ne04jdemo.entitiy.ScheConfigEntity;
import cn.scu.ne04jdemo.entitiy.ScheTimeWindowInfoEntity;
import cn.scu.ne04jdemo.service.ScheConfigService;
import cn.scu.ne04jdemo.service.ScheTimeWindowInfoService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/sche/config")
public class ScheConfigController {

    @Autowired
    private ScheConfigService scheConfigService;

    @GetMapping("/getInfo")
    public ResponseEntity<ScheConfigEntity> getInfo(){
        QueryWrapper<ScheConfigEntity> params = new QueryWrapper();
        ScheConfigEntity res = null;
        try {
            res = scheConfigService.getOne(params);
        }catch (Exception e){
            e.printStackTrace();
        }
        return ResponseEntity.ok(res);
    }

    @PostMapping("/update")
    @ResponseBody
    public Boolean update(@RequestBody ScheConfigEntity scheConfigEntity){
        try {
            scheConfigService.updateById(scheConfigEntity);
        }catch (Exception e){
            e.printStackTrace();
            return false;
        }
        return true;
    }

}
